var mysql = require('mysql');

function OptPool() {
	// 是否连接过
	this.flag = true;
	this.pool = mysql.createPool({
		host: 'localhost',        
		user: 'root',                
		password: 'admin',         
		database: 'student',  
		port: '3306'  
	});
	this.getPool = function() {
		if(this.flag){
			// 监听connection事件
			this.pool.on('connection', function(connection){
				connection.query('SET SESSION auto_increment_increment = 1');
				this.flag = false;
			});
		}
		return this.pool;
	};
}

module.exports = OptPool;
